class Solution {
public:
    int maxFrequencyElements(vector<int>& nums) {
        if(nums.empty()) return 0;
        vector<int> cnts(110);
        for(int i:nums)
            cnts[i]++;
        sort(cnts.begin(), cnts.end(), greater<int>());
        int ans=0, mx=cnts[0];
        if(mx==0) return 0;
        for(int i:cnts)
            if(mx==i) ans+=mx;
            else break;
        return ans;
    }
};